import 'package:FineArt/utils/size_config.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

/// 列表项
class GridItemPhoto1 extends StatelessWidget {
  // 文字
  final String url;

  //点击事件
  final Function onTap;
  final double width;
  final double height;
  final int index;
  final Color bgColor;
  final BoxFit boxFit;
  final int page;

  // 构造函数
  const GridItemPhoto1(
      {Key key,
      this.url,
      this.onTap,
      this.width,
      this.height = 0,
      this.index,
      this.bgColor = Colors.black,
      this.boxFit = BoxFit.fitWidth,
      this.page=-1})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
        onTap: () {
          this.onTap(index);
        },
        child: Container(
            color: bgColor,
            alignment: Alignment.center,
            child: Stack(
              alignment: Alignment.center,
              children: [
                Image(
                    fit: boxFit,
                    // width: width,
                    image: CachedNetworkImageProvider(
                      url,
                    )),
                Positioned(
                  bottom: getPortraitSHeight(8),
                    child: page<0?Divider(height: 0,):Container(
                      alignment: Alignment.center,
                      padding: EdgeInsets.symmetric(
                          vertical: 2, horizontal: getPortraitSWidth(8)),
                      decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(radius(20)),
                          color: Color.fromARGB(100, 0, 0, 0),),
                      child: Row(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          SizedBox(
                            width: getPortraitSWidth(0),
                          ),
                          Text(
                            "第$page页",
                            style:
                            TextStyle(color: Colors.white, fontSize: setSp(10)),
                          )
                        ],
                      ),
                    ))
              ],

            )));
  }
}
